package com.umeox.logger

class LoggerInterceptChainHandler {

    private var _interceptFirst: AbsLogInterceptChain? = null

    fun add(interceptChain: AbsLogInterceptChain?) {
        if (_interceptFirst == null) {
            _interceptFirst = interceptChain
            return
        }

        var node: AbsLogInterceptChain? = _interceptFirst

        while (true) {
            if (node?.next == null) {
                node?.next = interceptChain
                break
            }

            node = node.next
        }
    }

    fun intercept(priority: Int, tag: String, logMsg: String?, throwable: Throwable? = null) {
        _interceptFirst?.intercept(priority, tag, logMsg, throwable)
    }
}